/**
 * @file      condition.h
 * @copyright Copyright (c) 2020, ZCW Co., Ltd. All Rights Reserved.
 * @brief     brief
 * @author    caiwang213@qq.com
 * @date      2020-05-18 16:05:54
 *
 * @note
 *  condition.h defines
 */
#ifndef __CONDITION_H__
#define __CONDITION_H__
#include "mutex.h"

namespace log4x
{
class Condition
{
    CLASS_NO_COPY(Condition)
public:
    Condition(Mutex &mtx);
    ~Condition();
public:
    bool               wait(int ms = 0);
    void               notify();
    void               broadcast();
private:
    Mutex            & m_cond_mtx;

#ifdef _WIN32
    Mutex              m_mtx;
    long               m_counter;
    HANDLE             m_sema;
    HANDLE             m_handshake;
#else
    COND               m_cond;
#endif
};
}
#endif
